package com.jinmdz.fmis.api.api.controller;

import com.jinmdz.fmis.api.api.model.common.IdVersionData;
import com.jinmdz.fmis.api.api.model.settlement.SettleDailyExpensesAllLoadData;
import com.jinmdz.fmis.api.api.model.settlement.SettleDailyExpensesVerifyData;
import com.jinmdz.fmis.api.api.service.SettleDailyExpensesService;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.core.base.BaseResult;
import com.jinmdz.fmis.dao.model.settlement.SettleDailyExpensesAllData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * 费用结算日结相关接口
 *
 * @author LiCongLu
 * @date 2020-02-21 11:45
 */
@Api(description = "费用结算日结相关接口")
@RestController()
@RequestMapping("/api/settle-daily-expenses")
public class SettleDailyExpensesController extends BaseController {

    @Resource
    private SettleDailyExpensesService settleDailyExpensesService;

    /**
     * 根据查询条件加载页面数据信息，此接口为按页面定制接口
     *
     * @param data 加载条件
     * @return
     * @author LiCongLu
     * @date 2020-02-21 12:13
     */
    @ApiOperation(value = "根据查询条件加载页面数据信息，此接口为按页面定制接口", notes = "根据查询条件加载结算记录信息")
    @PostMapping("/load-settle-daily-expenses-all")
    public BaseResult<SettleDailyExpensesAllLoadData> loadSettleDailyExpensesAll(@RequestBody SettleDailyExpensesAllData data) {
        return resultHandler(data, userItem -> settleDailyExpensesService.loadSettleDailyExpensesAll(data));
    }

    /**
     * 创建日结单，费用日结审核
     *
     * @param data 创建日结审核数据
     * @return
     * @author LiCongLu
     * @date 2020-02-21 12:17
     */
    @ApiOperation(value = "创建日结单，费用日结审核", notes = "创建日结单，进行费用日结审核")
    @PostMapping("/save-settle-daily-expenses-verify")
    public BaseResult saveSettleDailyExpensesVerify(@RequestBody SettleDailyExpensesVerifyData data) {
        return resultHandler(data, userItem -> settleDailyExpensesService.saveSettleDailyExpensesVerify(userItem, data));
    }

    /**
     * 取消日结审核
     *
     * @param data 主键和版本号
     * @return
     * @author LiCongLu
     * @date 2020-02-21 12:21
     */
    @ApiOperation(value = "取消日结审核", notes = "根据日结单记录id，撤销日结操作")
    @PostMapping("/save-settle-daily-expenses-cancellation-verify")
    public BaseResult saveSettleDailyExpensesCancellationVerify(@RequestBody ArrayList<IdVersionData> data) {
        return resultHandler(userItem -> settleDailyExpensesService.saveSettleDailyExpensesCancellationVerify(userItem, data));
    }

}
